﻿<%@ Page Language="C#" %>

<%@ Import Namespace="System.Collections.Generic" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script type="text/C#" runat="server">
    public string GetSign(FooFun.GrantFrameworks.PermissionSet set)
    {
        switch (set)
        {
            case FooFun.GrantFrameworks.PermissionSet.Grant:
                return "√";
            case FooFun.GrantFrameworks.PermissionSet.Revoke:
                return "×";
            default:
                return "?";
        }
    }

    public void Page_Load(object sender, EventArgs e)
    {
        AccessGrant.GrantFrameworks.PermissionQuery query
            = AccessGrant.GrantFrameworks.PermissionQuery.Create();

        IEnumerable<IEnumItem> aList = query.ListAccount();
        IEnumerable<IEnumItem> pList = query.ListPermission();

        ForumManager manager = new ForumManager();
        FooFun.DataElements.Dtos.IDataElement de
            = manager.GetElement(FAQContext.Current.ForumId);

        HtmlTableRow header = new HtmlTableRow();
        HtmlTableCell cell = new HtmlTableCell();
        cell.InnerHtml = "&nbsp;";
        header.Cells.Add(cell);

        foreach (var item in aList)
        {
            cell = new HtmlTableCell();
            cell.InnerText = item.Name;
            cell.Attributes["title"] = PhysicalDataProvider.DataProviderUtil.GetGuidBase64(item.Id);

            header.Cells.Add(cell);
        }

        tbSet.Rows.Add(header);

        foreach (var item in pList)
        {
            HtmlTableRow row = new HtmlTableRow();

            cell = new HtmlTableCell();

            cell.InnerText = item.Name;
            cell.Attributes["title"] = PhysicalDataProvider.DataProviderUtil.GetGuidBase64(item.Id);

            row.Cells.Add(cell);

            foreach (var aItem in aList)
            {
                cell = new HtmlTableCell();
                cell.InnerText = GetSign
                (query[de as IEnumItem, aItem, item]);
                row.Cells.Add(cell);
            }

            tbSet.Rows.Add(row);
        }
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <table id="tbSet" runat="server" border="1">
    </table>
</body>
</html>
